* Model definition for CGE model with search and matching friction
 
* Note: Steady state model only



parameters
p_e_ss(ind,ind2)
p_e_c_ss(ind)
;

variables
p_ss_ct(ind)
p_c_ss_ct(ind)
p_cbar_ss_ct
exch_ss_ct

sub_ss_ct(ind)

p_f_ss_ct(ind)
p_c_f_ss_ct(ind)
p_cbar_f_ss_ct

lambda_ss_ct
lambda_f_ss_ct

lambdag_ss_ct
lambdag_f_ss_ct

cbar_ss_ct
c_ss_ct(ind)
cd_ss_ct(ind)
cf_ss_ct(ind)
v_n_ss_ct(ind)
v_ng_ss_ct
phibar_ss_ct


cbar_f_ss_ct
c_f_ss_ct(ind)
cd_f_ss_ct(ind)
cf_f_ss_ct(ind)
v_n_f_ss_ct(ind)
v_ng_f_ss_ct
phibar_f_ss_ct



w_ss_ct(ind)
h_ss_ct(ind)
w_f_ss_ct(ind)
h_f_ss_ct(ind)
wg_ss_ct
hg_ss_ct
wg_f_ss_ct
hg_f_ss_ct

vbar_ss_ct(ind)
j_n_ss_ct(ind)
f_l_ss_ct(ind)
f_v_ss_ct(ind)
vv_ss_ct(ind)
io_id_ss_ct(ind,ind2)
io_if_ss_ct(ind,ind2)
cost_df_ss_ct(ind,ind2)
cost_e_ss_ct(ind)
io_ie_ss_ct(ie,ind)
cost_m_ss_ct(ind)
io_im_ss_ct(im,ind)
cost_v_ss_ct(ind)
io_ev_ss_ct(ind)
io_mv_ss_ct(ind)
iod_ss_ct(ind,ind2)
iof_ss_ct(ind,ind2)
y_ss_ct(ind)
prof_ss_ct(ind)
e_ss_ct(ind)
etot_ss_ct

vbar_f_ss_ct(ind)
j_n_f_ss_ct(ind)
f_l_f_ss_ct(ind)
f_v_f_ss_ct(ind)
l_f_ss_ct(ind)
vv_f_ss_ct(ind)
io_id_f_ss_ct(ind,ind2)
io_if_f_ss_ct(ind,ind2)
cost_df_f_ss_ct(ind,ind2)
cost_e_f_ss_ct(ind)
io_ie_f_ss_ct(ie,ind)
cost_m_f_ss_ct(ind)
io_im_f_ss_ct(im,ind)
cost_v_f_ss_ct(ind)
io_ev_f_ss_ct(ind)
io_mv_f_ss_ct(ind)
iod_f_ss_ct(ind,ind2)
iof_f_ss_ct(ind,ind2)
y_f_ss_ct(ind)
prof_f_ss_ct(ind)


vbarg_ss_ct
cg_n_ss_ct
f_lg_ss_ct
f_vg_ss_ct
vvg_ss_ct
io_idg_ss_ct(ind)
io_ifg_ss_ct(ind)
cost_dfg_ss_ct(ind)
cost_eg_ss_ct
io_ieg_ss_ct(ie)
cost_mg_ss_ct
io_img_ss_ct(im)
cost_vg_ss_ct
io_evg_ss_ct
io_mvg_ss_ct
gd_ss_ct
gf_ss_ct


vbarg_f_ss_ct
cg_n_f_ss_ct
f_lg_f_ss_ct
f_vg_f_ss_ct
vvg_f_ss_ct
io_idg_f_ss_ct(ind)
io_ifg_f_ss_ct(ind)
cost_dfg_f_ss_ct(ind)
cost_eg_f_ss_ct
io_ieg_f_ss_ct(ie)
cost_mg_f_ss_ct
io_img_f_ss_ct(im)
cost_vg_f_ss_ct
io_evg_f_ss_ct
io_mvg_f_ss_ct
gd_f_ss_ct
gf_f_ss_ct

phi_i_ss_ct(ind)
q_ss_ct(ind)
theta_i_ss_ct(ind)
n_ss_ct(ind)

phi_g_ss_ct
qg_ss_ct
theta_g_ss_ct
ng_ss_ct

thetatot_ss_ct
ntot_ss_ct

phi_f_ss_ct(ind)
q_f_ss_ct(ind)
theta_f_ss_ct(ind)
n_f_ss_ct(ind)

phig_f_ss_ct
qg_f_ss_ct
thetag_f_ss_ct
ng_f_ss_ct

thetatot_f_ss_ct
ntot_f_ss_ct

grev_ss_ct
tlump_ss_ct
delta_tau
tau_l_ss_ct

grev_f_ss_ct
tlump_f_ss_ct

exports_ss_ct(ind)
imports_ss_ct(ind)

;



equations
eqn_p_cbar_ss_ct
eqn_p_c_ss_ct(ind)


eqn_p_cbar_f_ss_ct
eqn_p_c_f_ss_ct(ind)

eqn_hhfoc_ss_ct
eqn_bc_ss_ct
eqn_c_ss_ct(ind)
eqn_cd_ss_ct(ind)
eqn_cf_ss_ct(ind)

eqn_v_n_ss_ct(ind)
eqn_v_ng_ss_ct
eqn_phibar_ss_ct

eqn_hhfoc_f_ss_ct
eqn_bc_f_ss_ct
eqn_c_f_ss_ct(ind)
eqn_cd_f_ss_ct(ind)
eqn_cf_f_ss_ct(ind)

eqn_v_n_f_ss_ct(ind)
eqn_v_ng_f_ss_ct
eqn_phibar_f_ss_ct


eqn_nash_ss_ct(ind)
eqn_intra_ss_ct(ind)

eqn_nash_f_ss_ct(ind)
eqn_intra_f_ss_ct(ind)

eqn_nashg_ss_ct
eqn_intrag_ss_ct

eqn_nashg_f_ss_ct
eqn_intrag_f_ss_ct


eqn_foc_vbar_ss_ct(ind)
eqn_foc_v_ss_ct(ind)
eqn_foc_n_ss_ct(ind)
eqn_f_l_ss_ct(ind)
eqn_f_v_ss_ct(ind)
eqn_cost_df_ss_ct(ind,ind2)
eqn_io_id_ss_ct(ind,ind2)
eqn_io_if_ss_ct(ind,ind2)
eqn_cost_e_ss_ct(ind)
eqn_io_ie_ss_ct(ie,ind)
eqn_cost_m_ss_ct(ind)
eqn_io_im_ss_ct(im,ind)
eqn_cost_v_ss_ct(ind)
eqn_io_ev_ss_ct(ind)
eqn_io_mv_ss_ct(ind)
eqn_firm_iod_e_ss_ct(ie,ind)
eqn_firm_iod_m_ss_ct(im,ind)
eqn_firm_iof_e_ss_ct(ie,ind)
eqn_firm_iof_m_ss_ct(im,ind)
eqn_y_ss_ct(ind)
eqn_prof_ss_ct(ind)
eqn_e_ss_ct(ind)
eqn_etot_ss_ct


eqn_foc_vbar_f_ss_ct(ind)
eqn_foc_v_f_ss_ct(ind)
eqn_foc_n_f_ss_ct(ind)
eqn_f_l_f_ss_ct(ind)
eqn_f_v_f_ss_ct(ind)
eqn_cost_df_f_ss_ct(ind,ind2)
eqn_io_id_f_ss_ct(ind,ind2)
eqn_io_if_f_ss_ct(ind,ind2)
eqn_cost_e_f_ss_ct(ind)
eqn_io_ie_f_ss_ct(ie,ind)
eqn_cost_m_f_ss_ct(ind)
eqn_io_im_f_ss_ct(im,ind)
eqn_cost_v_f_ss_ct(ind)
eqn_io_ev_f_ss_ct(ind)
eqn_io_mv_f_ss_ct(ind)
eqn_firm_iod_e_f_ss_ct(ie,ind)
eqn_firm_iod_m_f_ss_ct(im,ind)
eqn_firm_iof_e_f_ss_ct(ie,ind)
eqn_firm_iof_m_f_ss_ct(im,ind)
eqn_y_f_ss_ct(ind)
eqn_prof_f_ss_ct(ind)

eqn_foc_vbarg_ss_ct
eqn_foc_vg_ss_ct
eqn_foc_ng_ss_ct
eqn_f_lg_ss_ct
eqn_f_vg_ss_ct
eqn_cost_dfg_ss_ct
eqn_io_idg_ss_ct
eqn_io_ifg_ss_ct
eqn_cost_eg_ss_ct
eqn_io_ieg_ss_ct(ie)
eqn_cost_mg_ss_ct
eqn_io_img_ss_ct(im)
eqn_cost_vg_ss_ct
eqn_io_evg_ss_ct
eqn_io_mvg_ss_ct
eqn_gd_e_ss_ct
eqn_gd_m_ss_ct
eqn_gf_e_ss_ct
eqn_gf_m_ss_ct

eqn_foc_vbarg_f_ss_ct
eqn_foc_vg_f_ss_ct
eqn_foc_ng_f_ss_ct
eqn_f_lg_f_ss_ct
eqn_f_vg_f_ss_ct
eqn_cost_dfg_f_ss_ct
eqn_io_idg_f_ss_ct
eqn_io_ifg_f_ss_ct
eqn_cost_eg_f_ss_ct
eqn_io_ieg_f_ss_ct(ie)
eqn_cost_mg_f_ss_ct
eqn_io_img_f_ss_ct(im)
eqn_cost_vg_f_ss_ct
eqn_io_evg_f_ss_ct
eqn_io_mvg_f_ss_ct
eqn_gd_f_e_ss_ct
eqn_gd_f_m_ss_ct
eqn_gf_f_e_ss_ct
eqn_gf_f_m_ss_ct


eqn_phi_i_ss_ct(ind)
eqn_q_ss_ct(ind)
eqn_theta_i_ss_ct(ind)
eqn_n_ss_ct(ind)

eqn_phi_g_ss_ct
eqn_qg_ss_ct
eqn_theta_g_ss_ct
eqn_ng_ss_ct

eqn_thetatot_ss_ct
eqn_ntot_ss_ct

eqn_phi_f_ss_ct(ind)
eqn_q_f_ss_ct(ind)
eqn_theta_f_ss_ct(ind)
eqn_n_f_ss_ct(ind)

eqn_phig_f_ss_ct
eqn_qg_f_ss_ct
eqn_thetag_f_ss_ct
eqn_ng_f_ss_ct


eqn_thetatot_f_ss_ct
eqn_ntot_f_ss_ct

eqn_sub_ss_ct

eqn_grev_ss_ct
eqn_tlump_ss_ct
eqn_tau_l_ss_ct
eqn_rr_ss_ct

eqn_grev_f_ss_ct
eqn_tlump_f_ss_ct

eqn_exports_ss_ct(ind)
eqn_imports_ss_ct(ind)
eqn_tbal_ss_ct

eqn_mc_ss_ct(ind)
eqn_mc_f_ss_ct(ind)
eqn_yg_ss_ct
eqn_yg_f_ss_ct
;

** Aggregate Prices

eqn_p_cbar_ss_ct.. p_cbar_ss_ct =e= gammac**(sigmac/(1-sigmac))*(sum(ind,(alphac(ind)**sigmac)*p_c_ss_ct(ind)**(1-sigmac)))**(1/(1-sigmac));
eqn_p_c_ss_ct(ind).. p_c_ss_ct(ind) =e= gammacf(ind)**(sig_c(ind)/(1-sig_c(ind)))*( (alphac_d(ind)**sig_c(ind))*((p_ss_ct(ind))**(1-sig_c(ind))) + (alphac_f(ind)**sig_c(ind))*(((p_f_ss_ct(ind)/exch_ss_ct)+tar_i2(ind)*p_e_c_ss(ind))**(1-sig_c(ind))) )**(1/(1-sig_c(ind)));

eqn_p_cbar_f_ss_ct.. p_cbar_f_ss_ct =e= gammac_ff**(sigmac/(1-sigmac))*(sum(ind,(alphac_ff(ind)**sigmac)*p_c_f_ss_ct(ind)**(1-sigmac)))**(1/(1-sigmac));
eqn_p_c_f_ss_ct(ind).. p_c_f_ss_ct(ind) =e= gammacf_f(ind)**(sig_c_f(ind)/(1-sig_c_f(ind)))*( (alphac_d_f(ind)**sig_c_f(ind))*((p_f_ss_ct(ind))**(1-sig_c_f(ind))) + (alphac_f_f(ind)**sig_c_f(ind))*(((p_ss_ct(ind)*exch_ss_ct) )**(1-sig_c_f(ind))) )**(1/(1-sig_c_f(ind)));

** Household


eqn_hhfoc_ss_ct.. cbar_ss_ct**(-sigma) =e= p_cbar_ss_ct*lambda_ss_ct;
eqn_bc_ss_ct.. (1-tau_l_ss_ct)*(sum(ind,n_ss_ct(ind)*w_ss_ct(ind)*h_ss_ct(ind)) + ng_ss_ct*wg_ss_ct*hg_ss_ct) + (1-ntot_ss_ct)*p_cbar_ss_ct*b0.l + p_cbar_ss_ct*tlump_ss_ct  + sum(ind,prof_ss_ct(ind))  - p_cbar_ss_ct*cbar_ss_ct =g= 0;
eqn_c_ss_ct(ind).. c_ss_ct(ind) =e= ((gammac*alphac(ind))**sigmac)*((p_cbar_ss_ct/p_c_ss_ct(ind))**sigmac)*cbar_ss_ct;
eqn_cd_ss_ct(ind).. cd_ss_ct(ind) =e= ((gammacf(ind)*alphac_d(ind))**sig_c(ind))*((p_c_ss_ct(ind)/p_ss_ct(ind))**sig_c(ind))*c_ss_ct(ind);
eqn_cf_ss_ct(ind).. cf_ss_ct(ind) =e= ((gammacf(ind)*alphac_f(ind))**sig_c(ind))*((p_c_ss_ct(ind)/((p_f_ss_ct(ind)/exch_ss_ct)+tar_i2(ind)*p_e_c_ss(ind)))**sig_c(ind))*c_ss_ct(ind);

eqn_v_n_ss_ct(ind).. v_n_ss_ct(ind) =e= ((1-tau)/tau)*((1-tau_l_ss_ct)/(1+tau_p0))*lambda_ss_ct*j_n_ss_ct(ind);
eqn_v_ng_ss_ct.. v_ng_ss_ct =e= ((1-tau)/tau)*((1-tau_l_ss_ct)/(1+tau_p0))*lambda_ss_ct*(-cg_n_ss_ct);
eqn_phibar_ss_ct.. phibar_ss_ct =e= beta*sum(ind,phi_i_ss_ct(ind)*v_n_ss_ct(ind)) + beta*phi_g_ss_ct*v_ng_ss_ct;

eqn_hhfoc_f_ss_ct.. (cbar_f_ss_ct/ratiof)**(-sigma) =e= p_cbar_f_ss_ct*lambda_f_ss_ct;
eqn_bc_f_ss_ct.. (1-tau_l0)*(sum(ind,n_f_ss_ct(ind)*w_f_ss_ct(ind)*h_f_ss_ct(ind)) + ng_f_ss_ct*wg_f_ss_ct*hg_f_ss_ct) + (ratiof-ntot_f_ss_ct)*p_cbar_f_ss_ct*b0_f.l + p_cbar_f_ss_ct*tlump_f_ss_ct  + sum(ind,prof_f_ss_ct(ind))  - p_cbar_f_ss_ct*cbar_f_ss_ct =g= 0;
eqn_c_f_ss_ct(ind).. c_f_ss_ct(ind) =e= ((gammac_ff*alphac_ff(ind))**sigmac)*((p_cbar_f_ss_ct/p_c_f_ss_ct(ind))**sigmac)*cbar_f_ss_ct;
eqn_cd_f_ss_ct(ind).. cd_f_ss_ct(ind) =e= ((gammacf_f(ind)*alphac_d_f(ind))**sig_c_f(ind))*((p_c_f_ss_ct(ind)/p_f_ss_ct(ind))**sig_c_f(ind))*c_f_ss_ct(ind);
eqn_cf_f_ss_ct(ind).. cf_f_ss_ct(ind) =e= ((gammacf_f(ind)*alphac_f_f(ind))**sig_c_f(ind))*((p_c_f_ss_ct(ind)/((p_ss_ct(ind)*exch_ss_ct)))**sig_c_f(ind))*c_f_ss_ct(ind);


eqn_v_n_f_ss_ct(ind).. v_n_f_ss_ct(ind) =e= ((1-tau)/tau)*((1-tau_l0)/(1+tau_p0))*lambda_f_ss_ct*j_n_f_ss_ct(ind);
eqn_v_ng_f_ss_ct.. v_ng_f_ss_ct =e= ((1-tau)/tau)*((1-tau_l0)/(1+tau_p0))*lambda_f_ss_ct*(-cg_n_f_ss_ct);
eqn_phibar_f_ss_ct.. phibar_f_ss_ct =e= beta*sum(ind,phi_f_ss_ct(ind)*v_n_f_ss_ct(ind)) + beta*phig_f_ss_ct*v_ng_f_ss_ct;

** Nash Bargaining


eqn_nash_ss_ct(ind).. (1-tau_l_ss_ct)*w_ss_ct(ind)*h_ss_ct(ind) =e= ((1-tau_l_ss_ct)/(1+tau_p0))*(1-tau)*( f_l_ss_ct(ind)*h_ss_ct(ind)*(p_ss_ct(ind)*(1+sub_ss_ct(ind)))  )
 + tau*((psi.l*(h_ss_ct(ind)**(1+chi))/(1+chi))/lambda_ss_ct + b0.l*p_cbar_ss_ct + phibar_ss_ct/lambda_ss_ct);

eqn_intra_ss_ct(ind).. (1-tau_l_ss_ct)*lambda_ss_ct*(f_l_ss_ct(ind)*p_ss_ct(ind)*(1+sub_ss_ct(ind))) =e= (1+tau_p0)*psi.l*(h_ss_ct(ind)**chi);

eqn_nash_f_ss_ct(ind).. (1-tau_l0)*w_f_ss_ct(ind)*h_f_ss_ct(ind) =e= ((1-tau_l0)/(1+tau_p0))*(1-tau)*( f_l_f_ss_ct(ind)*h_f_ss_ct(ind)*(p_f_ss_ct(ind)) + sum(ind2,(f_l_f_ss_ct(ind2)*p_f_ss_ct(ind2))*theta_f_ss_ct(ind2)) + lambdag_f_ss_ct*f_lg_f_ss_ct*thetag_f_ss_ct )
 + tau*((psi_f.l*(h_f_ss_ct(ind)**(1+chi))/(1+chi))/lambda_f_ss_ct + b0_f.l*p_cbar_f_ss_ct);

eqn_intra_f_ss_ct(ind).. (1-tau_l0)*lambda_f_ss_ct*(f_l_f_ss_ct(ind)*p_f_ss_ct(ind)) =e= (1+tau_p0)*psi_f.l*(h_f_ss_ct(ind)**chi);




eqn_nashg_ss_ct.. (1-tau_l_ss_ct)*wg_ss_ct*hg_ss_ct =e= ((1-tau_l_ss_ct)/(1+tau_p0))*(1-tau)*( f_lg_ss_ct*hg_ss_ct*(lambdag_ss_ct)  )
 + tau*((psi.l*(hg_ss_ct**(1+chi))/(1+chi))/lambda_ss_ct + b0.l*p_cbar_ss_ct  + phibar_ss_ct/lambda_ss_ct);

eqn_intrag_ss_ct.. (1-tau_l_ss_ct)*lambda_ss_ct*(f_lg_ss_ct*lambdag_ss_ct) =e= (1+tau_p0)*psi.l*(hg_ss_ct**chi);

eqn_nashg_f_ss_ct.. (1-tau_l0)*wg_f_ss_ct*hg_f_ss_ct =e= ((1-tau_l0)/(1+tau_p0))*(1-tau)*( f_lg_f_ss_ct*hg_f_ss_ct*(lambdag_f_ss_ct) + sum(ind2,(f_l_f_ss_ct(ind2)*p_f_ss_ct(ind2))*theta_f_ss_ct(ind2)) + lambdag_f_ss_ct*f_lg_f_ss_ct*thetag_f_ss_ct )
 + tau*((psi_f.l*(hg_f_ss_ct**(1+chi))/(1+chi))/lambda_f_ss_ct + b0_f.l*p_cbar_f_ss_ct);

eqn_intrag_f_ss_ct.. (1-tau_l0)*lambda_f_ss_ct*(f_lg_f_ss_ct*lambdag_f_ss_ct) =e= (1+tau_p0)*psi_f.l*(hg_f_ss_ct**chi);

** Firm

* First-order conditions for recruitment and intermediate inputs

eqn_foc_vbar_ss_ct(ind).. q_ss_ct(ind) =e= ((p_ss_ct(ind)*(1+sub_ss_ct(ind)))*f_l_ss_ct(ind))/(beta*j_n_ss_ct(ind));
eqn_foc_v_ss_ct(ind).. f_v_ss_ct(ind) =e= cost_v_ss_ct(ind)/(p_ss_ct(ind)*(1+sub_ss_ct(ind)));
eqn_foc_n_ss_ct(ind).. f_l_ss_ct(ind) =e= ((1-beta*(1-pi(ind)))*j_n_ss_ct(ind) + (1+tau_p0)*w_ss_ct(ind)*h_ss_ct(ind))/((p_ss_ct(ind)*(1+sub_ss_ct(ind)))*h_ss_ct(ind));
eqn_f_l_ss_ct(ind).. f_l_ss_ct(ind) =e= alphap.l(ind)*gammay_ss_ct(ind)*( alphap.l(ind)* (h_ss_ct(ind)*n_ss_ct(ind)*(1-vbar_ss_ct(ind)))**rho(ind) + (1-alphap.l(ind))*vv_ss_ct(ind)**rho(ind) )**(1/rho(ind)-1)*(h_ss_ct(ind)*n_ss_ct(ind)*(1-vbar_ss_ct(ind)))**(rho(ind)-1);
eqn_f_v_ss_ct(ind).. f_v_ss_ct(ind) =e= (1-alphap.l(ind))*gammay_ss_ct(ind)*( alphap.l(ind)* (h_ss_ct(ind)*n_ss_ct(ind)*(1-vbar_ss_ct(ind)))**rho(ind) + (1-alphap.l(ind))*vv_ss_ct(ind)**rho(ind) )**(1/rho(ind)-1)*vv_ss_ct(ind)**(rho(ind)-1);


eqn_foc_vbar_f_ss_ct(ind).. q_f_ss_ct(ind) =e= ((p_f_ss_ct(ind))*f_l_f_ss_ct(ind))/(beta*j_n_f_ss_ct(ind));
eqn_foc_v_f_ss_ct(ind).. f_v_f_ss_ct(ind) =e= cost_v_f_ss_ct(ind)/(p_f_ss_ct(ind));
eqn_foc_n_f_ss_ct(ind).. f_l_f_ss_ct(ind) =e= ((1-beta*(1-pi(ind)))*j_n_f_ss_ct(ind) + (1+tau_p0)*w_f_ss_ct(ind)*h_f_ss_ct(ind))/((p_f_ss_ct(ind))*h_f_ss_ct(ind));
eqn_f_l_f_ss_ct(ind).. f_l_f_ss_ct(ind) =e= alphap_f.l(ind)*gammay0_f.l(ind)*( alphap_f.l(ind)* (h_f_ss_ct(ind)*n_f_ss_ct(ind)*(1-vbar_f_ss_ct(ind)))**rho(ind) + (1-alphap_f.l(ind))*vv_f_ss_ct(ind)**rho(ind) )**(1/rho(ind)-1)*(h_f_ss_ct(ind)*n_f_ss_ct(ind)*(1-vbar_f_ss_ct(ind)))**(rho(ind)-1);
eqn_f_v_f_ss_ct(ind).. f_v_f_ss_ct(ind) =e= (1-alphap_f.l(ind))*gammay0_f.l(ind)*( alphap_f.l(ind)* (h_f_ss_ct(ind)*n_f_ss_ct(ind)*(1-vbar_f_ss_ct(ind)))**rho(ind) + (1-alphap_f.l(ind))*vv_f_ss_ct(ind)**rho(ind) )**(1/rho(ind)-1)*(vv_f_ss_ct(ind))**(rho(ind)-1);


* Intermediate input demand

eqn_cost_df_ss_ct(ind,ind2).. cost_df_ss_ct(ind,ind2) =e= gammadf(ind,ind2)**(sig_df(ind)/(1-sig_df(ind)))*( (alphadf_d(ind,ind2)**sig_df(ind))*((p_ss_ct(ind)+mu_e(ind,ind2)*p_e_ss(ind,ind2))**(1-sig_df(ind))) + (alphadf_f(ind,ind2)**sig_df(ind))*(((p_f_ss_ct(ind)/exch_ss_ct)+mu_e(ind,ind2)*p_e_ss(ind,ind2)+tar_i2(ind)*p_e_ss(ind,ind2))**(1-sig_df(ind))) )**(1/(1-sig_df(ind)));
eqn_io_id_ss_ct(ind,ind2).. io_id_ss_ct(ind,ind2) =e= ((gammadf(ind,ind2)*alphadf_d(ind,ind2))**sig_df(ind)) * ((p_ss_ct(ind)+mu_e(ind,ind2)*p_e_ss(ind,ind2))/cost_df_ss_ct(ind,ind2))**(-sig_df(ind));
eqn_io_if_ss_ct(ind,ind2).. io_if_ss_ct(ind,ind2)  =e=  ((gammadf(ind,ind2)*alphadf_f(ind,ind2))**sig_df(ind)) * (((p_f_ss_ct(ind)/exch_ss_ct)+mu_e(ind,ind2)*p_e_ss(ind,ind2)+tar_i2(ind)*p_e_ss(ind,ind2))/cost_df_ss_ct(ind,ind2))**(-sig_df(ind));
eqn_cost_e_ss_ct(ind).. cost_e_ss_ct(ind) =e= gammae(ind)**(sig_e(ind)/(1-sig_e(ind)))*( sum(ie, (alphae(ie,ind)**sig_e(ind))*(cost_df_ss_ct(ie,ind))**(1-sig_e(ind))) )**(1/(1-sig_e(ind)));
eqn_io_ie_ss_ct(ie,ind).. io_ie_ss_ct(ie,ind) =e= ((gammae(ind)*alphae(ie,ind))**sig_e(ind)) * (cost_df_ss_ct(ie,ind)/cost_e_ss_ct(ind))**(-sig_e(ind));
eqn_cost_m_ss_ct(ind).. cost_m_ss_ct(ind) =e= gammam(ind)**(sig_m(ind)/(1-sig_m(ind)))*( sum(im, (alpham(im,ind)**sig_m(ind))*(cost_df_ss_ct(im,ind))**(1-sig_m(ind))) )**(1/(1-sig_m(ind)));
eqn_io_im_ss_ct(im,ind).. io_im_ss_ct(im,ind) =e= ((gammam(ind)*alpham(im,ind))**sig_m(ind)) * (cost_df_ss_ct(im,ind)/cost_m_ss_ct(ind))**(-sig_m(ind));
eqn_cost_v_ss_ct(ind).. cost_v_ss_ct(ind) =e= gammav_ss(ind)**(sig_v(ind)/(1-sig_v(ind)))*( (alphav_e(ind)**sig_v(ind))*((cost_e_ss_ct(ind))**(1-sig_v(ind))) + (alphav_m(ind)**sig_v(ind))*((cost_m_ss_ct(ind))**(1-sig_v(ind))) )**(1/(1-sig_v(ind)));
eqn_io_ev_ss_ct(ind).. io_ev_ss_ct(ind) =e= ((gammav_ss(ind)*alphav_e(ind))**sig_v(ind)) * (cost_e_ss_ct(ind)/cost_v_ss_ct(ind))**(-sig_v(ind));
eqn_io_mv_ss_ct(ind).. io_mv_ss_ct(ind) =e= ((gammav_ss(ind)*alphav_m(ind))**sig_v(ind)) * (cost_m_ss_ct(ind)/cost_v_ss_ct(ind))**(-sig_v(ind));
eqn_firm_iod_e_ss_ct(ie,ind).. iod_ss_ct(ie,ind) =e= io_id_ss_ct(ie,ind)*io_ie_ss_ct(ie,ind)*io_ev_ss_ct(ind)*vv_ss_ct(ind);
eqn_firm_iod_m_ss_ct(im,ind).. iod_ss_ct(im,ind) =e= io_id_ss_ct(im,ind)*io_im_ss_ct(im,ind)*io_mv_ss_ct(ind)*vv_ss_ct(ind);
eqn_firm_iof_e_ss_ct(ie,ind).. iof_ss_ct(ie,ind) =e= io_if_ss_ct(ie,ind)*io_ie_ss_ct(ie,ind)*io_ev_ss_ct(ind)*vv_ss_ct(ind);
eqn_firm_iof_m_ss_ct(im,ind).. iof_ss_ct(im,ind) =e= io_if_ss_ct(im,ind)*io_im_ss_ct(im,ind)*io_mv_ss_ct(ind)*vv_ss_ct(ind);


eqn_cost_df_f_ss_ct(ind,ind2).. cost_df_f_ss_ct(ind,ind2) =e= gammadf_f(ind,ind2)**(sig_df(ind)/(1-sig_df(ind)))*( (alphadf_d_f(ind,ind2)**sig_df(ind))*((p_f_ss_ct(ind))**(1-sig_df(ind))) + (alphadf_f_f(ind,ind2)**sig_df(ind))*(((p_ss_ct(ind)*exch_ss_ct))**(1-sig_df(ind))) )**(1/(1-sig_df(ind)));
eqn_io_id_f_ss_ct(ind,ind2).. io_id_f_ss_ct(ind,ind2) =e= ((gammadf_f(ind,ind2)*alphadf_d_f(ind,ind2))**sig_df(ind)) * ((p_f_ss_ct(ind))/cost_df_f_ss_ct(ind,ind2))**(-sig_df(ind));
eqn_io_if_f_ss_ct(ind,ind2).. io_if_f_ss_ct(ind,ind2)  =e=  ((gammadf_f(ind,ind2)*alphadf_f_f(ind,ind2))**sig_df(ind)) * (((p_ss_ct(ind)*exch_ss_ct))/cost_df_f_ss_ct(ind,ind2))**(-sig_df(ind));
eqn_cost_e_f_ss_ct(ind).. cost_e_f_ss_ct(ind) =e= gammae_f(ind)**(sig_e(ind)/(1-sig_e(ind)))*( sum(ie, (alphae_f(ie,ind)**sig_e(ind))*(cost_df_f_ss_ct(ie,ind))**(1-sig_e(ind))) )**(1/(1-sig_e(ind)));
eqn_io_ie_f_ss_ct(ie,ind).. io_ie_f_ss_ct(ie,ind) =e= ((gammae_f(ind)*alphae_f(ie,ind))**sig_e(ind)) * (cost_df_f_ss_ct(ie,ind)/cost_e_f_ss_ct(ind))**(-sig_e(ind));
eqn_cost_m_f_ss_ct(ind).. cost_m_f_ss_ct(ind) =e= gammam_f(ind)**(sig_m(ind)/(1-sig_m(ind)))*( sum(im, (alpham_f(im,ind)**sig_m(ind))*(cost_df_f_ss_ct(im,ind))**(1-sig_m(ind))) )**(1/(1-sig_m(ind)));
eqn_io_im_f_ss_ct(im,ind).. io_im_f_ss_ct(im,ind) =e= ((gammam_f(ind)*alpham_f(im,ind))**sig_m(ind)) * (cost_df_f_ss_ct(im,ind)/cost_m_f_ss_ct(ind))**(-sig_m(ind));
eqn_cost_v_f_ss_ct(ind).. cost_v_f_ss_ct(ind) =e= gammav_f(ind)**(sig_v(ind)/(1-sig_v(ind)))*( (alphav_e_f(ind)**sig_v(ind))*((cost_e_f_ss_ct(ind))**(1-sig_v(ind))) + (alphav_m_f(ind)**sig_v(ind))*((cost_m_f_ss_ct(ind))**(1-sig_v(ind))) )**(1/(1-sig_v(ind)));
eqn_io_ev_f_ss_ct(ind).. io_ev_f_ss_ct(ind) =e= ((gammav_f(ind)*alphav_e_f(ind))**sig_v(ind)) * (cost_e_f_ss_ct(ind)/cost_v_f_ss_ct(ind))**(-sig_v(ind));
eqn_io_mv_f_ss_ct(ind).. io_mv_f_ss_ct(ind) =e= ((gammav_f(ind)*alphav_m_f(ind))**sig_v(ind)) * (cost_m_f_ss_ct(ind)/cost_v_f_ss_ct(ind))**(-sig_v(ind));
eqn_firm_iod_e_f_ss_ct(ie,ind).. iod_f_ss_ct(ie,ind) =e= io_id_f_ss_ct(ie,ind)*io_ie_f_ss_ct(ie,ind)*io_ev_f_ss_ct(ind)*vv_f_ss_ct(ind);
eqn_firm_iod_m_f_ss_ct(im,ind).. iod_f_ss_ct(im,ind) =e= io_id_f_ss_ct(im,ind)*io_im_f_ss_ct(im,ind)*io_mv_f_ss_ct(ind)*vv_f_ss_ct(ind);
eqn_firm_iof_e_f_ss_ct(ie,ind).. iof_f_ss_ct(ie,ind) =e= io_if_f_ss_ct(ie,ind)*io_ie_f_ss_ct(ie,ind)*io_ev_f_ss_ct(ind)*vv_f_ss_ct(ind);
eqn_firm_iof_m_f_ss_ct(im,ind).. iof_f_ss_ct(im,ind) =e= io_if_f_ss_ct(im,ind)*io_im_f_ss_ct(im,ind)*io_mv_f_ss_ct(ind)*vv_f_ss_ct(ind);

* Output and profits
eqn_y_ss_ct(ind).. y_ss_ct(ind) =e= gammay_ss_ct(ind)*(alphap.l(ind)*(h_ss_ct(ind)*n_ss_ct(ind)*(1-vbar_ss_ct(ind)))**rho(ind) + (1-alphap.l(ind))*vv_ss_ct(ind)**rho(ind))**(1/rho(ind));
eqn_prof_ss_ct(ind).. prof_ss_ct(ind) =e= (p_ss_ct(ind)*(1+sub_ss_ct(ind)))*y_ss_ct(ind) - (1+tau_p0)*w_ss_ct(ind)*n_ss_ct(ind)*h_ss_ct(ind) - cost_v_ss_ct(ind)*vv_ss_ct(ind) ;
eqn_e_ss_ct(ind).. e_ss_ct(ind) =e=  sum(ie,mu_e(ie,ind)*(iod_ss_ct(ie,ind)+iof_ss_ct(ie,ind))) + sum(secondary,sum(oilgas,mu_e(oilgas,secondary))*f_y0(secondary)*iof_ss_ct(secondary,ind));
eqn_etot_ss_ct.. etot_ss_ct =e= sum(ind,e_ss_ct(ind)) - sum(oilgas,sum(secondary,((iod_ss_ct(oilgas,secondary)+iof_ss_ct(oilgas,secondary))/y_ss_ct(secondary))*mu_e(oilgas,secondary)*exports_ss_ct(secondary))) + sum(oilgas,sum(secondary,f_y0(secondary)*mu_e(oilgas,secondary)*(cf_ss_ct(secondary)+gf_ss_ct(secondary))));

eqn_y_f_ss_ct(ind).. y_f_ss_ct(ind) =e= gammay0_f.l(ind)*(alphap_f.l(ind)*(h_f_ss_ct(ind)*n_f_ss_ct(ind)*(1-vbar_f_ss_ct(ind)))**rho(ind) + (1-alphap_f.l(ind))*vv_f_ss_ct(ind)**rho(ind))**(1/rho(ind));
eqn_prof_f_ss_ct(ind).. prof_f_ss_ct(ind) =e= (p_f_ss_ct(ind))*y_f_ss_ct(ind) - (1+tau_p0)*w_f_ss_ct(ind)*n_f_ss_ct(ind)*h_f_ss_ct(ind) - cost_v_f_ss_ct(ind)*vv_f_ss_ct(ind) ;


** Government

eqn_foc_vbarg_ss_ct.. qg_ss_ct =e= ((lambdag_ss_ct)*f_lg_ss_ct)/(beta*(-cg_n_ss_ct));
eqn_foc_vg_ss_ct.. lambdag_ss_ct*f_vg_ss_ct =e=  cost_vg_ss_ct;
eqn_foc_ng_ss_ct.. f_lg_ss_ct =e= ((beta*(1-pig)-1)*cg_n_ss_ct + (1+tau_p0)*wg_ss_ct*hg_ss_ct)/(lambdag_ss_ct*hg_ss_ct);
eqn_f_lg_ss_ct.. f_lg_ss_ct =e= alphapg.l*gammayg0.l*( alphapg.l* (hg_ss_ct*ng_ss_ct*(1-vbarg_ss_ct))**rhog + (1-alphapg.l)*vvg_ss_ct**rhog )**(1/rhog-1)*(hg_ss_ct*ng_ss_ct*(1-vbarg_ss_ct))**(rhog-1);
eqn_f_vg_ss_ct.. f_vg_ss_ct =e= (1-alphapg.l)*gammayg0.l*( alphapg.l* (hg_ss_ct*ng_ss_ct*(1-vbarg_ss_ct))**rhog + (1-alphapg.l)*vvg_ss_ct**rhog )**(1/rhog-1)*(vvg_ss_ct)**(rhog-1);

eqn_cost_dfg_ss_ct(ind).. cost_dfg_ss_ct(ind) =e= gammadfg(ind)**(sig_df(ind)/(1-sig_df(ind)))*( (alphadfg_d(ind)**sig_df(ind))*((p_ss_ct(ind))**(1-sig_df(ind))) + (alphadfg_f(ind)**sig_df(ind))*(((p_f_ss_ct(ind)/exch_ss_ct))**(1-sig_df(ind))) )**(1/(1-sig_df(ind)));
eqn_io_idg_ss_ct(ind).. io_idg_ss_ct(ind) =e= ((gammadfg(ind)*alphadfg_d(ind))**sig_df(ind)) * ((p_ss_ct(ind))/cost_dfg_ss_ct(ind))**(-sig_df(ind));
eqn_io_ifg_ss_ct(ind).. io_ifg_ss_ct(ind)  =e=  ((gammadfg(ind)*alphadfg_f(ind))**sig_df(ind)) * (((p_f_ss_ct(ind)/exch_ss_ct))/cost_dfg_ss_ct(ind))**(-sig_df(ind));
eqn_cost_eg_ss_ct.. cost_eg_ss_ct =e= gammaeg**(sig_eg/(1-sig_eg))*( sum(ie, (alphaeg(ie)**sig_eg)*(cost_dfg_ss_ct(ie))**(1-sig_eg)) )**(1/(1-sig_eg));
eqn_io_ieg_ss_ct(ie).. io_ieg_ss_ct(ie) =e= ((gammaeg*alphaeg(ie))**sig_eg) * ((cost_dfg_ss_ct(ie))/cost_eg_ss_ct)**(-sig_eg);
eqn_cost_mg_ss_ct.. cost_mg_ss_ct =e= gammamg**(sig_mg/(1-sig_mg))*( sum(im, (alphamg(im)**sig_mg)*(cost_dfg_ss_ct(im))**(1-sig_mg)) )**(1/(1-sig_mg));
eqn_io_img_ss_ct(im).. io_img_ss_ct(im) =e= ((gammamg*alphamg(im))**sig_mg) * (cost_dfg_ss_ct(im)/cost_mg_ss_ct)**(-sig_mg);
eqn_cost_vg_ss_ct.. cost_vg_ss_ct =e= gammavg**(sig_vg/(1-sig_vg))*( (alphavg_e**sig_vg)*((cost_eg_ss_ct)**(1-sig_vg)) + (alphavg_m**sig_vg)*((cost_mg_ss_ct)**(1-sig_vg)) )**(1/(1-sig_vg));
eqn_io_evg_ss_ct.. io_evg_ss_ct =e= ((gammavg*alphavg_e)**sig_vg) * (cost_eg_ss_ct/cost_vg_ss_ct)**(-sig_vg);
eqn_io_mvg_ss_ct.. io_mvg_ss_ct =e= ((gammavg*alphavg_m)**sig_vg) * (cost_mg_ss_ct/cost_vg_ss_ct)**(-sig_vg);
eqn_gd_e_ss_ct(ie).. gd_ss_ct(ie) =e= vvg_ss_ct*io_evg_ss_ct*io_ieg_ss_ct(ie)*io_idg_ss_ct(ie);
eqn_gd_m_ss_ct(im).. gd_ss_ct(im) =e= vvg_ss_ct*io_mvg_ss_ct*io_img_ss_ct(im)*io_idg_ss_ct(im);
eqn_gf_e_ss_ct(ie).. gf_ss_ct(ie) =e= vvg_ss_ct*io_evg_ss_ct*io_ieg_ss_ct(ie)*io_ifg_ss_ct(ie);
eqn_gf_m_ss_ct(im).. gf_ss_ct(im) =e= vvg_ss_ct*io_mvg_ss_ct*io_img_ss_ct(im)*io_ifg_ss_ct(im);

eqn_foc_vbarg_f_ss_ct.. qg_f_ss_ct =e= ((lambdag_f_ss_ct)*f_lg_f_ss_ct)/(beta*(-cg_n_f_ss_ct));
eqn_foc_vg_f_ss_ct.. lambdag_f_ss_ct*f_vg_f_ss_ct =e=  cost_vg_f_ss_ct;
eqn_foc_ng_f_ss_ct.. f_lg_f_ss_ct =e= ((beta*(1-pig_f)-1)*cg_n_f_ss_ct + (1+tau_p0)*wg_f_ss_ct*hg_f_ss_ct)/(lambdag_f_ss_ct*hg_f_ss_ct);
eqn_f_lg_f_ss_ct.. f_lg_f_ss_ct =e= alphapg_f.l*gammayg0_f.l*( alphapg_f.l* (hg_f_ss_ct*ng_f_ss_ct*(1-vbarg_f_ss_ct))**rhog + (1-alphapg_f.l)*vvg_f_ss_ct**rhog )**(1/rhog-1)*(hg_f_ss_ct*ng_f_ss_ct*(1-vbarg_f_ss_ct))**(rhog-1);
eqn_f_vg_f_ss_ct.. f_vg_f_ss_ct =e= (1-alphapg_f.l)*gammayg0_f.l*( alphapg_f.l* (hg_f_ss_ct*ng_f_ss_ct*(1-vbarg_f_ss_ct))**rhog + (1-alphapg_f.l)*vvg_f_ss_ct**rhog )**(1/rhog-1)*(vvg_f_ss_ct)**(rhog-1);



eqn_cost_dfg_f_ss_ct(ind).. cost_dfg_f_ss_ct(ind) =e= gammadfg_f(ind)**(sig_df(ind)/(1-sig_df(ind)))*( (alphadfg_d_f(ind)**sig_df(ind))*((p_f_ss_ct(ind))**(1-sig_df(ind))) + (alphadfg_f_f(ind)**sig_df(ind))*(((p_ss_ct(ind)*exch_ss_ct))**(1-sig_df(ind))) )**(1/(1-sig_df(ind)));
eqn_io_idg_f_ss_ct(ind).. io_idg_f_ss_ct(ind) =e= ((gammadfg_f(ind)*alphadfg_d_f(ind))**sig_df(ind)) * ((p_f_ss_ct(ind))/cost_dfg_f_ss_ct(ind))**(-sig_df(ind));
eqn_io_ifg_f_ss_ct(ind).. io_ifg_f_ss_ct(ind)  =e=  ((gammadfg_f(ind)*alphadfg_f_f(ind))**sig_df(ind)) * (((p_ss_ct(ind)*exch_ss_ct))/cost_dfg_f_ss_ct(ind))**(-sig_df(ind));
eqn_cost_eg_f_ss_ct.. cost_eg_f_ss_ct =e= gammaeg_f**(sig_eg/(1-sig_eg))*( sum(ie, (alphaeg_f(ie)**sig_eg)*(cost_dfg_f_ss_ct(ie))**(1-sig_eg)) )**(1/(1-sig_eg));
eqn_io_ieg_f_ss_ct(ie).. io_ieg_f_ss_ct(ie) =e= ((gammaeg_f*alphaeg_f(ie))**sig_eg) * ((cost_dfg_f_ss_ct(ie))/cost_eg_f_ss_ct)**(-sig_eg);
eqn_cost_mg_f_ss_ct.. cost_mg_f_ss_ct =e= gammamg_f**(sig_mg/(1-sig_mg))*( sum(im, (alphamg_f(im)**sig_mg)*(cost_dfg_f_ss_ct(im))**(1-sig_mg)) )**(1/(1-sig_mg));
eqn_io_img_f_ss_ct(im).. io_img_f_ss_ct(im) =e= ((gammamg_f*alphamg_f(im))**sig_mg) * (cost_dfg_f_ss_ct(im)/cost_mg_f_ss_ct)**(-sig_mg);
eqn_cost_vg_f_ss_ct.. cost_vg_f_ss_ct =e= gammavg_f**(sig_vg/(1-sig_vg))*( (alphavg_e_f**sig_vg)*((cost_eg_f_ss_ct)**(1-sig_vg)) + (alphavg_m_f**sig_vg)*((cost_mg_f_ss_ct)**(1-sig_vg)) )**(1/(1-sig_vg));
eqn_io_evg_f_ss_ct.. io_evg_f_ss_ct =e= ((gammavg_f*alphavg_e_f)**sig_vg) * (cost_eg_f_ss_ct/cost_vg_f_ss_ct)**(-sig_vg);
eqn_io_mvg_f_ss_ct.. io_mvg_f_ss_ct =e= ((gammavg_f*alphavg_m_f)**sig_vg) * (cost_mg_f_ss_ct/cost_vg_f_ss_ct)**(-sig_vg);
eqn_gd_f_e_ss_ct(ie).. gd_f_ss_ct(ie) =e= vvg_f_ss_ct*io_evg_f_ss_ct*io_ieg_f_ss_ct(ie)*io_idg_f_ss_ct(ie);
eqn_gd_f_m_ss_ct(im).. gd_f_ss_ct(im) =e= vvg_f_ss_ct*io_mvg_f_ss_ct*io_img_f_ss_ct(im)*io_idg_f_ss_ct(im);
eqn_gf_f_e_ss_ct(ie).. gf_f_ss_ct(ie) =e= vvg_f_ss_ct*io_evg_f_ss_ct*io_ieg_f_ss_ct(ie)*io_ifg_f_ss_ct(ie);
eqn_gf_f_m_ss_ct(im).. gf_f_ss_ct(im) =e= vvg_f_ss_ct*io_mvg_f_ss_ct*io_img_f_ss_ct(im)*io_ifg_f_ss_ct(im);


eqn_sub_ss_ct(ind).. p_ss_ct(ind)*sub_ss_ct(ind) =e= sum(ie,p_e_ss(ie,ind)*mu_e(ie,ind)*(iod_ss_ct(ie,ind)+iof_ss_ct(ie,ind)) + tar_i2(ie)*p_e_ss(ie,ind)*iof_ss_ct(ie,ind) )/y_ss_ct(ind) ;

eqn_grev_ss_ct.. grev_ss_ct =e= ( (tau_l_ss_ct+tau_p0)*(sum(ind,n_ss_ct(ind)*w_ss_ct(ind)*h_ss_ct(ind)) + ng_ss_ct*wg_ss_ct*hg_ss_ct) + sum(ie,sum(ind,p_e_ss(ie,ind)*mu_e(ie,ind)*(iod_ss_ct(ie,ind)+iof_ss_ct(ie,ind))) ) - sum(ind,p_ss_ct(ind)*sub_ss_ct(ind)*y_ss_ct(ind)) + sum(ind,tar_i2(ind)*sum(ind2,p_e_ss(ind,ind2)*iof_ss_ct(ind,ind2))) + sum(ind,tar_i2(ind)*p_e_c_ss(ind)*cf_ss_ct(ind))   )/p_cbar_ss_ct;
eqn_tlump_ss_ct.. tlump_ss_ct =e= ( grev_ss_ct*p_cbar_ss_ct - (1-ntot_ss_ct)*p_cbar_ss_ct*b0.l - cost_vg_ss_ct*vvg_ss_ct -(1+tau_p0)*ng_ss_ct*wg_ss_ct*hg_ss_ct)/p_cbar_ss_ct;
eqn_tau_l_ss_ct.. tau_l_ss_ct =e= tau_l0*delta_tau;
eqn_rr_ss_ct.. grev_ss_ct =e= grev_ss;

eqn_grev_f_ss_ct.. grev_f_ss_ct =e= ( (tau_l0+tau_p0)*(sum(ind,n_f_ss_ct(ind)*w_f_ss_ct(ind)*h_f_ss_ct(ind)) + ng_f_ss_ct*wg_f_ss_ct*hg_f_ss_ct) )/p_cbar_f_ss_ct;
eqn_tlump_f_ss_ct.. tlump_f_ss_ct =e= ( grev_f_ss_ct*p_cbar_f_ss_ct - (ratiof-ntot_f_ss_ct)*p_cbar_f_ss_ct*b0_f.l -  cost_vg_f_ss_ct*vvg_f_ss_ct -(1+tau_p0)*ng_f_ss_ct*wg_f_ss_ct*hg_f_ss_ct)/p_cbar_f_ss_ct;


** Labor Market

eqn_phi_i_ss_ct(ind).. phi_i_ss_ct(ind) =e= mu.l(ind)*(theta_i_ss_ct(ind)*thetatot_ss_ct**(-gamma));
eqn_q_ss_ct(ind).. q_ss_ct(ind) =e= mu.l(ind)*(thetatot_ss_ct**(-gamma));
eqn_theta_i_ss_ct(ind).. theta_i_ss_ct(ind) =e= (vbar_ss_ct(ind)*n_ss_ct(ind)*h_ss_ct(ind))/(1-ntot_ss_ct);
eqn_n_ss_ct(ind).. n_ss_ct(ind) =e= phi_i_ss_ct(ind)*(1-ntot_ss_ct)/(pi(ind));

eqn_phi_g_ss_ct.. phi_g_ss_ct =e= mug.l*(theta_g_ss_ct*thetatot_ss_ct**(-gamma) );
eqn_qg_ss_ct.. qg_ss_ct =e= mug.l*(thetatot_ss_ct**(-gamma) );
eqn_theta_g_ss_ct.. theta_g_ss_ct =e= hg_ss_ct*vbarg_ss_ct*ng_ss_ct/(1-ntot_ss_ct);
eqn_ng_ss_ct.. ng_ss_ct =e= phi_g_ss_ct*(1-ntot_ss_ct)/(pig);

eqn_thetatot_ss_ct.. thetatot_ss_ct =e= sum(ind,theta_i_ss_ct(ind)) + theta_g_ss_ct;
eqn_ntot_ss_ct.. ntot_ss_ct =e= sum(ind,n_ss_ct(ind)) + ng_ss_ct;


eqn_phi_f_ss_ct(ind).. phi_f_ss_ct(ind) =e= mu_f.l(ind)*theta_f_ss_ct(ind)*thetatot_f_ss_ct**(-gamma);
eqn_q_f_ss_ct(ind).. q_f_ss_ct(ind) =e= mu_f.l(ind)*thetatot_f_ss_ct**(-gamma);
eqn_theta_f_ss_ct(ind).. theta_f_ss_ct(ind) =e= vbar_f_ss_ct(ind)*h_f_ss_ct(ind)*n_f_ss_ct(ind)/(ratiof-ntot_f_ss_ct);
eqn_n_f_ss_ct(ind).. n_f_ss_ct(ind) =e= (ratiof-ntot_f_ss_ct)*phi_f_ss_ct(ind)/(pi_f(ind));

eqn_phig_f_ss_ct.. phig_f_ss_ct =e= mug_f.l*thetag_f_ss_ct*thetatot_f_ss_ct**(-gamma);
eqn_qg_f_ss_ct.. qg_f_ss_ct =e= mug_f.l*thetatot_f_ss_ct**(-gamma);
eqn_thetag_f_ss_ct.. thetag_f_ss_ct =e= vbarg_f_ss_ct*hg_f_ss_ct*ng_f_ss_ct/(ratiof-ntot_f_ss_ct);
eqn_ng_f_ss_ct.. ng_f_ss_ct =e= (ratiof-ntot_f_ss_ct)*phig_f_ss_ct/(pig_f);

eqn_thetatot_f_ss_ct.. thetatot_f_ss_ct =e= (sum(ind,vbar_f_ss_ct(ind)*h_f_ss_ct(ind)*n_f_ss_ct(ind)) + vbarg_f_ss_ct*hg_f_ss_ct*ng_f_ss_ct)/(ratiof-ntot_f_ss_ct);
eqn_ntot_f_ss_ct.. ntot_f_ss_ct =e= sum(ind,n_f_ss_ct(ind)) + ng_f_ss_ct;


** Trade

eqn_imports_ss_ct(ind).. imports_ss_ct(ind) =e= sum(ind2,iof_ss_ct(ind,ind2)) + cf_ss_ct(ind) + gf_ss_ct(ind);
eqn_exports_ss_ct(ind).. exports_ss_ct(ind) =e= sum(ind2,iof_f_ss_ct(ind,ind2)) + cf_f_ss_ct(ind) + gf_f_ss_ct(ind);
eqn_tbal_ss_ct.. sum(ind,p_ss_ct(ind)*exports_ss_ct(ind) - (p_f_ss_ct(ind)/exch_ss_ct)*imports_ss_ct(ind)) =e= 0;

** Market Clearing

eqn_mc_ss_ct(ind).. y_ss_ct(ind) =g= cd_ss_ct(ind) + gd_ss_ct(ind) +  exports_ss_ct(ind) + sum(ind2,iod_ss_ct(ind,ind2));
eqn_mc_f_ss_ct(ind).. y_f_ss_ct(ind) =g= cd_f_ss_ct(ind) + gd_f_ss_ct(ind) +  imports_ss_ct(ind) + sum(ind2,iod_f_ss_ct(ind,ind2));

eqn_yg_ss_ct.. gammayg0.l*( alphapg.l*(hg_ss_ct*ng_ss_ct*(1-vbarg_ss_ct))**rhog + (1-alphapg.l)*vvg_ss_ct**rhog)**(1/rhog) =g= yg0;
eqn_yg_f_ss_ct.. gammayg0_f.l*( alphapg_f.l*(hg_f_ss_ct*ng_f_ss_ct*(1-vbarg_f_ss_ct))**rhog + (1-alphapg_f.l)*vvg_f_ss_ct**rhog)**(1/rhog) =g= yg0_f;


* Initialization

p_ss_ct.l(ind) = 1;
p_ss_ct.fx('i22') = 1;
p_cbar_ss_ct.l = 1;
p_c_ss_ct.l(ind) = 1;
exch_ss_ct.l = 1;

sub_ss_ct.l(ind) = 0;

p_f_ss_ct.l(ind) = 1;
p_f_ss_ct.fx('i22') = 1;
p_cbar_f_ss_ct.l = 1;
p_c_f_ss_ct.l(ind) = 1;


lambda_ss_ct.l = lambda_ss;
lambda_f_ss_ct.l = lambda_f_ss;

lambdag_ss_ct.l = lambdag_ss;
lambdag_f_ss_ct.l = lambdag_f_ss;

cbar_ss_ct.l = cbar_ss;
c_ss_ct.l(ind) = c0(ind);
cd_ss_ct.l(ind) = c_d0(ind);
cf_ss_ct.l(ind) = c_f0(ind);

v_n_ss_ct.l(ind) = v_n_ss.l(ind);
v_ng_ss_ct.l = v_ng_ss.l;
phibar_ss_ct.l = phitot_ss.l;

cbar_f_ss_ct.l = cbar_f_ss;
c_f_ss_ct.l(ind) = c0_f(ind);
cd_f_ss_ct.l(ind) = c_d0_f(ind);
cf_f_ss_ct.l(ind) = c_f0_f(ind);

v_n_f_ss_ct.l(ind) = v_n_f_ss.l(ind);
v_ng_f_ss_ct.l = v_ng_f_ss.l;
phibar_f_ss_ct.l = phitot_f_ss.l;



w_ss_ct.l(ind) = w_ss.l(ind);
h_ss_ct.l(ind) = h_ss.l(ind);
w_f_ss_ct.l(ind) = w_f_ss.l(ind);
h_f_ss_ct.l(ind) = h_f_ss.l(ind);
wg_ss_ct.l = wg_ss.l;
hg_ss_ct.l = hg_ss.l;
wg_f_ss_ct.l = wg_f_ss.l;
hg_f_ss_ct.l = hg_f_ss.l;



vbar_ss_ct.l(ind) = vbar_ss.l(ind);
j_n_ss_ct.l(ind) = j_n_ss.l(ind);
f_l_ss_ct.l(ind) = f_l_ss.l(ind);
f_v_ss_ct.l(ind) = f_v_ss.l(ind);
vv_ss_ct.l(ind) = vv0(ind);
cost_df_ss_ct.l(ind,ind2) = cost_df0(ind,ind2);
io_id_ss_ct.l(ind,ind2) = io_id0(ind,ind2);
io_if_ss_ct.l(ind,ind2) = io_if0(ind,ind2);
cost_e_ss_ct.l(ind) = cost_e0(ind);
io_ie_ss_ct.l(ie,ind) = io_ie0(ie,ind);
cost_m_ss_ct.l(ind) = cost_m0(ind);
io_im_ss_ct.l(im,ind) = io_im0(im,ind);
cost_v_ss_ct.l(ind) = cost_v0(ind);
io_ev_ss_ct.l(ind) = io_ev0(ind);
io_mv_ss_ct.l(ind) = io_mv0(ind);
iod_ss_ct.l(ind,ind2) = iod0(ind,ind2);
iof_ss_ct.l(ind,ind2) = iof0(ind,ind2);

y_ss_ct.l(ind) = y0(ind);
prof_ss_ct.l(ind) = prof_ss(ind);
e_ss_ct.l(ind) = e0(ind);
etot_ss_ct.l = etot0;

vbar_f_ss_ct.l(ind) = vbar_f_ss.l(ind);
j_n_f_ss_ct.l(ind) = j_n_f_ss.l(ind);
f_l_f_ss_ct.l(ind) = f_l_f_ss.l(ind);
f_v_f_ss_ct.l(ind) = f_v_f_ss.l(ind);
vv_f_ss_ct.l(ind) = vv0_f(ind);
cost_df_f_ss_ct.l(ind,ind2) = cost_df0_f(ind,ind2);
io_id_f_ss_ct.l(ind,ind2) = io_id0_f(ind,ind2);
io_if_f_ss_ct.l(ind,ind2) = io_if0_f(ind,ind2);
cost_e_f_ss_ct.l(ind) = cost_e0_f(ind);
io_ie_f_ss_ct.l(ie,ind) = io_ie0_f(ie,ind);
cost_m_f_ss_ct.l(ind) = cost_m0_f(ind);
io_im_f_ss_ct.l(im,ind) = io_im0_f(im,ind);
cost_v_f_ss_ct.l(ind) = cost_v0_f(ind);
io_ev_f_ss_ct.l(ind) = io_ev0_f(ind);
io_mv_f_ss_ct.l(ind) = io_mv0_f(ind);
iod_f_ss_ct.l(ind,ind2) = iod0_f(ind,ind2);
iof_f_ss_ct.l(ind,ind2) = iof0_f(ind,ind2);

y_f_ss_ct.l(ind) = y0_f(ind);
prof_f_ss_ct.l(ind) = prof_f_ss(ind);

vbarg_ss_ct.l = vbarg_ss.l;
cg_n_ss_ct.l = cg_n_ss.l;
f_lg_ss_ct.l = f_lg_ss.l;
f_vg_ss_ct.l = f_vg_ss.l;
vvg_ss_ct.l = gtot0;
io_idg_ss_ct.l(ind) = io_idg0(ind);
io_ifg_ss_ct.l(ind) = io_ifg0(ind);
cost_dfg_ss_ct.l(ind) = cost_dfg0(ind);
cost_eg_ss_ct.l = cost_eg0;
io_ieg_ss_ct.l(ie) = io_ieg0(ie);
cost_mg_ss_ct.l = cost_mg0;
io_img_ss_ct.l(im) = io_img0(im);
cost_vg_ss_ct.l = cost_vg0;
io_evg_ss_ct.l = io_evg0;
io_mvg_ss_ct.l = io_mvg0;
gd_ss_ct.l(ind) = g_d0(ind);
gf_ss_ct.l(ind) = g_f0(ind);

vbarg_f_ss_ct.l = vbarg_f_ss.l;
cg_n_f_ss_ct.l = cg_n_f_ss.l;
f_lg_f_ss_ct.l = f_lg_f_ss.l;
f_vg_f_ss_ct.l = f_vg_f_ss.l;
vvg_f_ss_ct.l = gtot0_f;
io_idg_f_ss_ct.l(ind) = io_idg0_f(ind);
io_ifg_f_ss_ct.l(ind) = io_ifg0_f(ind);
cost_dfg_f_ss_ct.l(ind) = cost_dfg0_f(ind);
cost_eg_f_ss_ct.l = cost_eg0_f;
io_ieg_f_ss_ct.l(ie) = io_ieg0_f(ie);
cost_mg_f_ss_ct.l = cost_mg0_f;
io_img_f_ss_ct.l(im) = io_img0_f(im);
cost_vg_f_ss_ct.l = cost_vg0_f;
io_evg_f_ss_ct.l = io_evg0_f;
io_mvg_f_ss_ct.l = io_mvg0_f;
gd_f_ss_ct.l(ind) = g_d0_f(ind);
gf_f_ss_ct.l(ind) = g_f0_f(ind);

phi_i_ss_ct.l(ind) = phi_i_ss.l(ind);
q_ss_ct.l(ind) = q_ss.l(ind);
theta_i_ss_ct.l(ind) = theta_i_ss.l(ind);
n_ss_ct.l(ind) = n_ss.l(ind);

phi_g_ss_ct.l = phi_g_ss.l;
qg_ss_ct.l = qg_ss.l;
theta_g_ss_ct.l = theta_g_ss.l;
ng_ss_ct.l = ng_ss.l;

thetatot_ss_ct.l = thetatot_ss.l;
ntot_ss_ct.l = ntot_ss.l;

phi_f_ss_ct.l(ind) = phi_f_ss.l(ind);
q_f_ss_ct.l(ind) = q_f_ss.l(ind);
theta_f_ss_ct.l(ind) = theta_f_ss.l(ind);
n_f_ss_ct.l(ind) = n_f_ss.l(ind);

phig_f_ss_ct.l = phig_f_ss.l;
qg_f_ss_ct.l = qg_f_ss.l;
thetag_f_ss_ct.l = thetag_f_ss.l;
ng_f_ss_ct.l = ng_f_ss.l;

thetatot_f_ss_ct.l = thetatot_f_ss.l;
ntot_f_ss_ct.l = ntot_f_ss.l;

grev_ss_ct.l = grev_ss;
tlump_ss_ct.l = tlump_ss;
tau_L_ss_ct.l = tau_l0;
delta_tau.l = 1;

grev_f_ss_ct.l = grev_f_ss;
tlump_f_ss_ct.l = tlump_f_ss;

exports_ss_ct.l(ind) = exports0(ind) ;
imports_ss_ct.l(ind) = imports0(ind);





model hwc_ss_ct /
eqn_p_cbar_ss_ct.p_cbar_ss_ct
eqn_p_c_ss_ct.p_c_ss_ct


eqn_p_cbar_f_ss_ct.p_cbar_f_ss_ct
eqn_p_c_f_ss_ct.p_c_f_ss_ct

eqn_hhfoc_ss_ct.cbar_ss_ct
eqn_bc_ss_ct.lambda_ss_ct
eqn_c_ss_ct.c_ss_ct
eqn_cd_ss_ct.cd_ss_ct
eqn_cf_ss_ct.cf_ss_ct

eqn_v_n_ss_ct.v_n_ss_ct
eqn_v_ng_ss_ct.v_ng_ss_ct
eqn_phibar_ss_ct.phibar_ss_ct

eqn_hhfoc_f_ss_ct.cbar_f_ss_ct
eqn_bc_f_ss_ct.lambda_f_ss_ct
eqn_c_f_ss_ct.c_f_ss_ct
eqn_cd_f_ss_ct.cd_f_ss_ct
eqn_cf_f_ss_ct.cf_f_ss_ct

eqn_nash_ss_ct.w_ss_ct
eqn_intra_ss_ct.h_ss_ct
eqn_nashg_ss_ct.wg_ss_ct
eqn_intrag_ss_ct.hg_ss_ct

eqn_nash_f_ss_ct.w_f_ss_ct
eqn_intra_f_ss_ct.h_f_ss_ct
eqn_nashg_f_ss_ct.wg_f_ss_ct
eqn_intrag_f_ss_ct.hg_f_ss_ct

eqn_foc_vbar_ss_ct.vbar_ss_ct
eqn_foc_v_ss_ct.vv_ss_ct
eqn_foc_n_ss_ct.j_n_ss_ct
eqn_f_l_ss_ct.f_l_ss_ct
eqn_f_v_ss_ct.f_v_ss_ct
eqn_cost_df_ss_ct.cost_df_ss_ct
eqn_io_id_ss_ct.io_id_ss_ct
eqn_io_if_ss_ct.io_if_ss_ct
eqn_cost_e_ss_ct.cost_e_ss_ct
eqn_io_ie_ss_ct.io_ie_ss_ct
eqn_cost_m_ss_ct.cost_m_ss_ct
eqn_io_im_ss_ct.io_im_ss_ct
eqn_cost_v_ss_ct.cost_v_ss_ct
eqn_io_ev_ss_ct.io_ev_ss_ct
eqn_io_mv_ss_ct.io_mv_ss_ct
eqn_firm_iod_e_ss_ct.iod_ss_ct
eqn_firm_iod_m_ss_ct.iod_ss_ct
eqn_firm_iof_e_ss_ct.iof_ss_ct
eqn_firm_iof_m_ss_ct.iof_ss_ct
eqn_y_ss_ct.y_ss_ct
eqn_prof_ss_ct.prof_ss_ct
eqn_e_ss_ct.e_ss_ct
eqn_etot_ss_ct.etot_ss_ct

eqn_foc_vbar_f_ss_ct.vbar_f_ss_ct
eqn_foc_v_f_ss_ct.vv_f_ss_ct
eqn_foc_n_f_ss_ct.j_n_f_ss_ct
eqn_f_l_f_ss_ct.f_l_f_ss_ct
eqn_f_v_f_ss_ct.f_v_f_ss_ct
eqn_cost_df_f_ss_ct.cost_df_f_ss_ct
eqn_io_id_f_ss_ct.io_id_f_ss_ct
eqn_io_if_f_ss_ct.io_if_f_ss_ct
eqn_cost_e_f_ss_ct.cost_e_f_ss_ct
eqn_io_ie_f_ss_ct.io_ie_f_ss_ct
eqn_cost_m_f_ss_ct.cost_m_f_ss_ct
eqn_io_im_f_ss_ct.io_im_f_ss_ct
eqn_cost_v_f_ss_ct.cost_v_f_ss_ct
eqn_io_ev_f_ss_ct.io_ev_f_ss_ct
eqn_io_mv_f_ss_ct.io_mv_f_ss_ct
eqn_firm_iod_e_f_ss_ct.iod_f_ss_ct
eqn_firm_iod_m_f_ss_ct.iod_f_ss_ct
eqn_firm_iof_e_f_ss_ct.iof_f_ss_ct
eqn_firm_iof_m_f_ss_ct.iof_f_ss_ct
eqn_y_f_ss_ct.y_f_ss_ct
eqn_prof_f_ss_ct.prof_f_ss_ct

eqn_foc_vbarg_ss_ct.vbarg_ss_ct
eqn_foc_vg_ss_ct.vvg_ss_ct
eqn_foc_ng_ss_ct.cg_n_ss_ct
eqn_f_lg_ss_ct.f_lg_ss_ct
eqn_f_vg_ss_ct.f_vg_ss_ct
eqn_cost_dfg_ss_ct.cost_dfg_ss_ct
eqn_io_idg_ss_ct.io_idg_ss_ct
eqn_io_ifg_ss_ct.io_ifg_ss_ct
eqn_cost_eg_ss_ct.cost_eg_ss_ct
eqn_io_ieg_ss_ct.io_ieg_ss_ct
eqn_cost_mg_ss_ct.cost_mg_ss_ct
eqn_io_img_ss_ct.io_img_ss_ct
eqn_cost_vg_ss_ct.cost_vg_ss_ct
eqn_io_evg_ss_ct.io_evg_ss_ct
eqn_io_mvg_ss_ct.io_mvg_ss_ct
eqn_gd_e_ss_ct.gd_ss_ct
eqn_gd_m_ss_ct.gd_ss_ct
eqn_gf_e_ss_ct.gf_ss_ct
eqn_gf_m_ss_ct.gf_ss_ct

eqn_foc_vbarg_f_ss_ct.vbarg_f_ss_ct
eqn_foc_vg_f_ss_ct.vvg_f_ss_ct
eqn_foc_ng_f_ss_ct.cg_n_f_ss_ct
eqn_f_lg_f_ss_ct.f_lg_f_ss_ct
eqn_f_vg_f_ss_ct.f_vg_f_ss_ct
eqn_cost_dfg_f_ss_ct.cost_dfg_f_ss_ct
eqn_io_idg_f_ss_ct.io_idg_f_ss_ct
eqn_io_ifg_f_ss_ct.io_ifg_f_ss_ct
eqn_cost_eg_f_ss_ct.cost_eg_f_ss_ct
eqn_io_ieg_f_ss_ct.io_ieg_f_ss_ct
eqn_cost_mg_f_ss_ct.cost_mg_f_ss_ct
eqn_io_img_f_ss_ct.io_img_f_ss_ct
eqn_cost_vg_f_ss_ct.cost_vg_f_ss_ct
eqn_io_evg_f_ss_ct.io_evg_f_ss_ct
eqn_io_mvg_f_ss_ct.io_mvg_f_ss_ct
eqn_gd_f_e_ss_ct.gd_f_ss_ct
eqn_gd_f_m_ss_ct.gd_f_ss_ct
eqn_gf_f_e_ss_ct.gf_f_ss_ct
eqn_gf_f_m_ss_ct.gf_f_ss_ct


eqn_sub_ss_ct.sub_ss_ct

eqn_grev_ss_ct.grev_ss_ct
eqn_tlump_ss_ct.tlump_ss_ct
eqn_tau_l_ss_ct.tau_l_ss_ct
eqn_rr_ss_ct.delta_tau

eqn_grev_f_ss_ct.grev_f_ss_ct
eqn_tlump_f_ss_ct.tlump_f_ss_ct



eqn_phi_i_ss_ct.phi_i_ss_ct
eqn_q_ss_ct.q_ss_ct
eqn_theta_i_ss_ct.theta_i_ss_ct
eqn_n_ss_ct.n_ss_ct

eqn_phi_g_ss_ct.phi_g_ss_ct
eqn_qg_ss_ct.qg_ss_ct
eqn_theta_g_ss_ct.theta_g_ss_ct
eqn_ng_ss_ct.ng_ss_ct

eqn_thetatot_ss_ct.thetatot_ss_ct
eqn_ntot_ss_ct.ntot_ss_ct

eqn_phi_f_ss_ct.phi_f_ss_ct
eqn_q_f_ss_ct.q_f_ss_ct
eqn_theta_f_ss_ct.theta_f_ss_ct
eqn_n_f_ss_ct.n_f_ss_ct
eqn_phig_f_ss_ct.phig_f_ss_ct
eqn_qg_f_ss_ct.qg_f_ss_ct
eqn_thetag_f_ss_ct.thetag_f_ss_ct
eqn_ng_f_ss_ct.ng_f_ss_ct
eqn_thetatot_f_ss_ct.thetatot_f_ss_ct
eqn_ntot_f_ss_ct.ntot_f_ss_ct

eqn_exports_ss_ct.exports_ss_ct
eqn_imports_ss_ct.imports_ss_ct
eqn_tbal_ss_ct.exch_ss_ct

eqn_mc_ss_ct.p_ss_ct
eqn_yg_ss_ct.lambdag_ss_ct
eqn_mc_f_ss_ct.p_f_ss_ct
eqn_yg_f_ss_ct.lambdag_f_ss_ct/
;

